﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Peojct2
{ /// <summary>
/// 包装或分装
/// </summary>
  public   class Casing
    {

        


        //静态方法
        public static DataTable GetDataTable(string sql)
        {
            //数据库连接字符串
       string conString = "server =.; database=taba;uid=sa;pwd=525200wai;";

        //初始化一个SqlConnection 连接类型对象
        SqlConnection connection = new SqlConnection(conString);


            //获取数据的关键代码  连接管理器
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);

            //打开命令
            connection.Open();

            DataTable dt = new DataTable();
            //需要数据
            adapter.Fill(dt);
            return dt;

        }
       /* public  static int AddOrUpdate(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
           return command.ExecuteNonQuery();
            
        }
        */
    }
}
